<template>
  <div class="cell_group">
    <div class="cell">
      <div class="title">
        {{config.attrName}}
      </div>
      <div class="picker" @click="goSelectCar">
        <div class="select-car" :class="{'placeholder':!pickerValue}">
          {{pickerValue?pickerValue:' 请选择轮胎信息'}} <!--由尹琳琳确认2019/09/02 -->
        </div>
        <img src="@/assets/img/right.png" alt="">
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "tyre_number",
  props: {
    config: {
      type: Object,
      required: true
    },
    parentIndex: Number,
    itemIndex: Number
  },
  data() {
    return {
      popupShow: false,
      pickerValue: ""
    };
  },
  created() {
    let tyreInfo = JSON.parse(this.$store.state.tyreInfo),
      that = this;
    if (tyreInfo.length) {
      tyreInfo.forEach(element => {
        if (element.name == that.config.attrName) {
          that.config.value = element.list[0].tyreBrand + "/" + element.list[1].tyreSpec;
          that.pickerValue = that.config.value;

          that.$emit(
            "changeValue",
            that.parentIndex,
            that.itemIndex,
            that.config
          );
        }
      });
    } else if (this.config.value) {
      this.pickerValue = this.config.value;
    } else {
      this.config.value = "";
    }
  },
  watch: {
    config(n) {
      //  
      if (n.value) {
        this.pickerValue = n.value;
        // this.$store.commit("onChoosecarInfo", n.value);
      }
    }
  },
  methods: {
    goSelectCar() {
      this.$router.replace({
        name: "tyre_number",
        params: { name: this.config.attrName }
      });
      //   /api/v1/datadictionary/select/{parentId}  轮胎接口
    }
  }
};
</script>
<style lang="less">
.picker {
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 0.4rem;
  font-family: PingFangSC-Regular;
  color: #666666;
  width: 60%;
  height: 100%;

  img {
    width: 0.186667rem;
    height: 0.346667rem;
    padding-left: 0.213333rem;
  }
  .select-car {
    width: calc(100% - 0.186667rem);
    height: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    justify-content: flex-end;
    line-height: 1.333333rem;
  }
  .placeholder {
    color: #dadada;
    font-size:16px;
  }
}
</style>

